﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace Black.SurfaceToolkit.Effects
{
    /// <summary>
    /// ToonShaderEffect Effect
    /// </summary>
    public class ToonShaderEffect : ShaderEffect
    {
        #region Propriétées de dépendances

        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ToonShaderEffect), 0);

        #endregion

        #region Accesseurs

        /// <summary>
        /// Affecte ou retourne la propriété Input du Shader
        /// </summary>
        [System.ComponentModel.BrowsableAttribute(false)]
        public Brush Input
        {
            get
            {
                return ((Brush)this.GetValue(ToonShaderEffect.InputProperty));
            }
            set
            {
                this.SetValue(ToonShaderEffect.InputProperty, value);
            }
        }

        #endregion

        #region Variables statiques

        private static readonly PixelShader _PixelShader = new PixelShader();

        #endregion

        #region Constructeurs

        /// <summary>
        /// Constructeur statique
        /// </summary>
        static ToonShaderEffect()
        {
            ToonShaderEffect._PixelShader.UriSource = new Uri("pack://application:,,,/Black.SurfaceToolkit;component/Effects/Shaders/ToonShader.ps");
            ToonShaderEffect._PixelShader.ShaderRenderMode = ShaderRenderMode.HardwareOnly;
        }

        /// <summary>
        /// Constructeur de la classe
        /// </summary>
        public ToonShaderEffect()
        {
            this.PixelShader = ToonShaderEffect._PixelShader;

            this.UpdateShaderValue(ToonShaderEffect.InputProperty);
        }

        #endregion
    }
}
